package com.example.demo.model;

import com.example.demo.enums.ResultStatus;
import lombok.Data;

@Data
public class Result <T>{
    private T data;
    private String ErrMsg;
    private ResultStatus code;

    public static <T> Result<T> success(T data){
        Result<T> result=new Result<>();
        result.setCode(ResultStatus.SUCCESS);
        result.setData(data);
        result.setErrMsg("");
        return result;
    }

    public static <T> Result<T> fail(String ErrMsg){
        Result<T> result=new Result<>();
        result.setCode(ResultStatus.FAIL);
        result.setErrMsg(ErrMsg);
        return result;
    }

    @Override
    public String toString() {
        return "Result{" +
                "data=" + data +
                ", ErrMsg='" + ErrMsg + '\'' +
                ", code=" + code +
                '}';
    }
}
